package pers.xhh.shopapi.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import pers.xhh.shopapi.annotation.UserLoginToken;
import pers.xhh.shopapi.common.Mi;
import pers.xhh.shopapi.service.MiGoodsAttrService;

/**
 * @author wei-xhh
 * @date 2020-12-13
 */
@CrossOrigin
@RestController
@RequestMapping("/api/v1")
public class MiGoodsAttrController {

    @Autowired
    MiGoodsAttrService miGoodsAttrService;

    @UserLoginToken
    @GetMapping("/goods/attr/{id}")
    public Mi getAttrById(@PathVariable Integer id){
        return miGoodsAttrService.getAttrById(id);
    }

    @UserLoginToken
    @PutMapping("/goods/attr/{id}")
    public Mi updateAttrById(@PathVariable Integer id,
                             @RequestParam("attrValue") String attrValue){
        return miGoodsAttrService.updateAttrById(id, attrValue);
    }

    @UserLoginToken
    @DeleteMapping("/goods/attr/{id}")
    public Mi deleteAttr(@PathVariable Integer id){
        return miGoodsAttrService.deleteAttr(id);
    }

}
